import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

import routes from '@/router/routes'
const originPush = VueRouter.prototype.push
const originReplace = VueRouter.prototype.replace
VueRouter.prototype.push = function (location, resolved, rejected) {
    if (resolved === undefined && rejected === undefined) {
        return originPush.call(this, location).catch(() => {})
    } else {
        return originPush.call(this, location, resolved, rejected)
    }
}

VueRouter.prototype.replace = function (location, resolved, rejected) {
    if (resolved === undefined && rejected === undefined) {
        return originReplace.call(this, location).catch(() => {})
    } else {
        return originReplace.call(this, location, resolved, rejected)
    }
}
const router =new VueRouter({
    mode:'hash',
    routes,
    scrollBehavior (to, from, savedPosition) {
        return { y: 0 }
      }
})
export default router
